package com.ztgf.user.api.cms;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.common.utils.StrUtils;
import com.ztgf.user.models.vo.UserImVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import com.ztgf.user.models.service.IUserImService;
import com.ztgf.user.models.bo.UserImSaveBO;
import com.ztgf.user.models.bo.UserImBO;
import com.ztgf.user.models.dto.UserImDTO;

/**
 * im账号表控制器
 *
 * @author zhanghualang
 * @Date 2020-05-28 17:48:46
 */

@RestController
@RequestMapping("/cms/userIm")
@Slf4j
@Api(value = "UserImController",tags = "im账号表接口")
public class UserImController {

    @DubboReference
    private IUserImService userImService;

    @ApiOperation(value = "修改im账号权重",notes = "修改im账号权重")
    @PostMapping("/update")
    public Result update(Long id, Integer consultationSort){
        if (id == null || consultationSort == null){
            return new Result<>(CodeEnum.FAIL_100002);
        }

        UserImDTO dto = new UserImDTO();
        dto.setId(id);
        dto.setConsultationSort(consultationSort);
        boolean flag = userImService.updateById(dto);
        if (flag){
            return new Result<>();
        } else {
            return new Result<>(CodeEnum.FAIL_100008);
        }
    }

    @ApiOperation(value = "im系统账号表列表",notes = "im系统账号表列表")
    @PostMapping("/queryPageList")
    public Result<Page<UserImVO>> queryPageList(UserImBO bo){
        Page<UserImVO> page = userImService.queryPageList(bo);
        return new Result<>(page);
    }
}
